<template>
    <div class="j-flag">
        <div class="return false;">
         <table class="m-table ">
             <thead>
                 <tr>
                    <th class="first w1">
                        <div class="wp">&nbsp;</div>
                    </th>
                     <th>
                         <div class="wp af0"></div>
                    </th>
                    <th class="w2">
                        <div class="wp af1"></div>
                    </th>
                    <th class="w3">
                        <div class="wp af2"></div>
                    </th>
                    <th class="w4">
                        <div class="wp af3"></div>
                    </th>
                 </tr>
             </thead>
             <tbody>
                 <tr :class="[{'enev':index%2 == 0},{'js-dis':item.noCopyrightRcmd}]"  v-for="(item , index) in playlistdata" :key="index">
                    <td class="left">
                        <div class="hd ">
                            <span :class="['ply' ,{'ply-z-slt':play_icon === index}]"  @click="play(item.id ,index,$event)">&nbsp;</span>
                            <span class="num">{{index+1}}</span>
                        </div>
                    </td>
                    <td class="">
                        <div class="tt">
                            <div class="ttc" @click.stop="toSong(item.id)">
                                {{item.name}}
                            </div>
                        </div>
                    </td>
                     <td class="">
                        <div class="tt">
                            <div class="ttc">
                              {{item.dt | date}}
                            </div>
                        </div>
                    </td>
                    <td class="">
                        <div class="tt">
                            <div class="ttc">
                                <a v-for="(A_item , A_index) in item.ar" :key="A_index" @click.stop="to_artistDetails(A_item.id)">{{A_item.name}}<slot v-if="A_index < item.ar.length -1">/</slot> </a>
                            </div>
                        </div>
                    </td>
                    <td class="">
                        <div class="tt">
                            <div class="ttc">
                                <a  @click.stop="to_album(item.al.id)">{{item.al.name}}</a>
                            </div>
                        </div>
                    </td>
                 </tr>
             </tbody>
         </table>
        </div>
    </div>
</template>

<script>
import {durationTime} from '../../../components/tool/tool'
export default {
    props:["listdata"],
    data() {
        return {
            playlistdata:"",
            play_icon:null
        }
    },
    methods:{
         play(id , index , e){   //点击播放 播放歌曲
           this.$store.dispatch("music_ct",{music_id:id , pageY:e.pageY})
            this.play_icon = index
         },
         toSong(id){
            this.$router.push({path:'/home/song' , query:{id:id}})
         },
         to_artistDetails(id){
             this.$router.push({path:'/home/artistDetails' , query:{id:id}})
         },
         to_album(id){
             this.$router.push({path:'/home/album' , query:{id:id}})
         }
    },
    filters:{
           date(v){
              var a =  durationTime(v)
             return a
           }
    },
    watch:{
       listdata(value){
          this.playlistdata = value
          this.play_icon = null
       }
   },
   created(){
      this.playlistdata = this.listdata
   }
}
</script>

<style scoped>
.m-table {
    width: 100%;
    min-height: 50px;
    border: 1px solid #d9d9d9;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: fixed;
}
thead {
    display: table-header-group;
    vertical-align: middle;
    border-color: inherit;
}
tr {
    display: table-row;
    vertical-align: inherit;
    border-color: inherit;
}
.m-table tr .w1 {
    width: 74px;
}
.m-table th {
    height: 38px;
    background-color: #f7f7f7;
    background-image: url("https://s2.music.126.net/style/web2/img/table.png?ce3ebe8c775c3b65c99e82397ff33542") ;
    background-position: 0 0;
    background-repeat: repeat-x;
    vertical-align: top;
    text-align: left;
    font-weight: normal;
    color: #666;
}
th{
    padding: 0;
    margin: 0;
}
.m-table th.first .wp {
    height: 18px;
    line-height: 18px;
    padding: 8px 10px;
    background:url("https://s2.music.126.net/style/web2/img/table.png?ce3ebe8c775c3b65c99e82397ff33542") no-repeat;
    background-position: 0 -56px;
}
.m-table th .wp {
    height: 18px;
    line-height: 18px;
    padding: 8px 10px;
    background:url("https://s2.music.126.net/style/web2/img/table.png?ce3ebe8c775c3b65c99e82397ff33542") no-repeat;
    background-position: 0 -56px;
}
.m-table .af0:after {
    content: '\6b4c \66f2 \6807 \9898';
    font-size: 12px;
}
.m-table .w2 {
    width: 111px;
}
.m-table .af1:after {
    content: '\65f6 \957f';
    font-size: 12px;
}
.m-table .w3 {
    width: 14%;
}
.m-table .af2:after {
    content: '\6b4c \624b';
    font-size: 12px;
}
.m-table .w4 {
    width: 20%;
}

.m-table .af3:after {
    content: '\4e13 \8f91';
    font-size: 12px;
}
.m-table .enev td {
    background-color: #f7f7f7;
}
.m-table td {
    padding: 6px 10px;
    line-height: 18px;
    text-align: left;
  
}
.m-table .hd {
    height: 18px;
}
.m-table .hd .ply {
    float: right;
    width: 17px;
    height: 17px;
    cursor: pointer;
     background:url("https://s2.music.126.net/style/web2/img/table.png?ce3ebe8c775c3b65c99e82397ff33542") no-repeat;
    background-position: 0 -103px;
}
.m-table .hd .ply-z-slt , .m-table .hd .ply:hover{
    background-position: -20px -128px;
}
.m-table .hd .num {
    width: 25px;
    margin-left: 5px;
    color: #999;
    font-size: 15px;
    font-family: Arial, Helvetica, sans-serif;
}
.m-table .tt {
    float: left;
    width: 100%;
}
.m-table .ttc {
    height: 18px;
    margin-right: 10px;
    font-size: 12px;
    color: #333;
    font-family: Arial, Helvetica, sans-serif;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.m-table .ttc:hover{
    text-decoration: underline;
    cursor: pointer;
}
.m-table .js-dis * {
    color: #bbb;
}
.m-table .js-dis .ply, .m-table .js-dis .ply:hover {
    opacity: 0.5;
    background-position: 0 -103px;
    cursor: default;
}
</style>